#ifndef __advanceMapFormat_h
#define __advanceMapFormat_h
#include <fstream>
#include "Palette.h"

using namespace std;

class AdvanceMap:public PaletteFormat
{
	SmartObject_Type_Information("Advance-Map Palette Format")
public:
	AdvanceMap():PaletteFormat("GBA-colors only. Saves into Advance-Map's palette format."){
		mArguments.Append("string filename;");
	}
	void Save( const Palette& pal, const SmartArray<SmartString>& args)
	{
		std::ofstream output(args[0].operator const char* (),ios::binary|ios::out);
		if( output.good())
		{
			for( unsigned int i=0; i<16; i++)
			{
				Color& __col = pal[i];
				int col = (__col.Red()) | (__col.Green() << 8) | (__col.Blue() << 16);
				output.write((char*)&col, 4);
			}
			output.close();
		}
		else
		{
		}
	}
	void Open( Palette& pal, const SmartArray<SmartString>& args)
	{
		ifstream output(args[0],ios::binary|ios::in);
		if( output.good())
		{
			for( unsigned int i=0; i<16; i++)
			{
				int col;
				if(!output.eof())
					output.read((char*)&col, 4);
				else break;
			}
		}
		else
		{
		}
	}
};
#endif